package work.base.data.stream;

/**
 * @author shenminglong@kedacom.com
 * @date 2021-12-17
 */
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class parallelStreamTest {

    public static void main(String[] args) {

        System.out.println(Test.name);
    }

    static class Test{
        public static String name;

        static {
            name = getName();
        }

        private static String getName(){
            List<String> datas = new ArrayList<>();
            for (int i = 0; i < 10; i++) {
                datas.add("a" + i);
            }

            datas = datas.parallelStream().filter(s -> s.equalsIgnoreCase("a9")).collect(Collectors.toList());
            //  匿名内部类
            datas = datas.parallelStream()
                    .filter(new Predicate<String>() {
                        @Override
                        public boolean test(String s) {
                            return s.equalsIgnoreCase("a9");
                        }
                    }).collect(Collectors.toList());


            return datas.get(0);
        }
    }
}
